<!DOCTYPE html>
<html lang="en">
<head>
<title>漂亮的响应式Bootstrap后台管理系统模板MatAdmin</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="__ROOT__/PUBLIC/css/bootstrap.min.css" />
<!-- <link rel="stylesheet" href="__ROOT__/PUBLIC/css/bootstrap-responsive.min.css" /> -->
<link rel="stylesheet" href="__ROOT__/PUBLIC/css/fullcalendar.css" />
<link rel="stylesheet" href="__ROOT__/PUBLIC/css/matrix-style.css" />
<link rel="stylesheet" href="__ROOT__/PUBLIC/css/matrix-media.css" />
<link rel="stylesheet" href="__ROOT__/PUBLIC/css/index.css" />
<link href="__ROOT__/PUBLIC/font-awesome/css/font-awesome.css" rel="stylesheet" />
<link rel="stylesheet" href="__ROOT__/PUBLIC/css/jquery.gritter.css" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
<script src="__ROOT__/PUBLIC/js/jquery-1.8.0.min.js"></script> 
    <style type="text/css">
		#allmap{width:100%;height:450px;}
	</style>
	<style>
        html, body, #container {
            height: 100%;
            width: 100%;
        }

        .amap-icon img,
        .amap-marker-content img{
            width: 25px;
            height: 34px;
        }

        .marker {
            position: absolute;
            top: -20px;
            right: -118px;
            color: #fff;
            padding: 4px 10px;
            box-shadow: 1px 1px 1px rgba(10, 10, 10, .2);
            white-space: nowrap;
            font-size: 12px;
            font-family: "";
            background-color: #25A5F7;
            border-radius: 3px;
        }

        .input-card{
            width: 18rem;
            z-index: 170;
        }

        .input-card .btn{
            margin-right: .8rem;
        }

        .input-card .btn:last-child{
            margin-right: 0;
        }
    </style>
   
<style>

.parent {
	display: block;
	height:0px;
    padding-bottom:100%
}

.parent {
	 writing-mode: horizontal-tb; 
}

.child {
	margin: 10px 10px 10px 10px;
	border: 5px solid black;
	padding: 5px;
	width: 450px;
	height: 750px;
	text-align: center;
	background: lightblue;
	writing-mode: horizontal-tb;
	display: inline-block;
}
</style>
<style>
#newwwf{position:relative;width:100%;height:1200px;border:2px solid #000;margin:10px auto;overflow:hidden;}
#allmap,#bottom{height:700px;overflow:hidden;}
#line{position:absolute;top:58%;width:100%;height:4px;overflow:hidden;margin-top:-2px;background:red;cursor:n-resize;}
</style>
<!-- <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=hNx4DUGHj4NRfZZIlfmSkkaxpwe1r8Zj"></script> -->
	  <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=9236cca4395c6f2a6e7dbd58677501c5"></script>   
</head>
<body>
        
<!--Header-part-->
<div id="header">
  <h1><a href="dashboard.html">MatAdmin</a></h1>
</div>
<!--close-Header-part-->
<!--top-Header-menu-->
<div id="user-nav" class="navbar navbar-inverse">
  <ul class="nav">
    <li  class="dropdown" id="profile-messages" ><a title="" href="#" data-toggle="dropdown" data-target="#profile-messages" class="dropdown-toggle"><i class="icon icon-user"></i>  <span id="userbeifn" class="text">{$user}</span><b class="caret"></b></a>
      <ul class="dropdown-menu">
        <li><a href="#"><i class="icon-user"></i> 我的资料</a></li>
        <li class="divider"></li>
        <li><a href="#"><i class="icon-check"></i> 我的任务</a></li>
        <li class="divider"></li>
        <li><a href="{:U('Login/logout')}"><i class="icon-key"></i> 退出</a></li>
      </ul>
    </li>
    <li class="dropdown" id="menu-messages"><a href="#" data-toggle="dropdown" data-target="#menu-messages" class="dropdown-toggle"><i class="icon icon-envelope"></i> <span class="text">消息</span> <span class="label label-important">5</span> <b class="caret"></b></a>
      <ul class="dropdown-menu">
        <li><a class="sAdd" title="" href="#"><i class="icon-plus"></i> 新消息</a></li>
        <li class="divider"></li>
        <li><a class="sInbox" title="" href="#"><i class="icon-envelope"></i> 收件箱</a></li>
        <li class="divider"></li>
        <li><a class="sOutbox" title="" href="#"><i class="icon-arrow-up"></i> 发件箱</a></li>
        <li class="divider"></li>
        <li><a class="sTrash" title="" href="#"><i class="icon-trash"></i> 发送</a></li>
      </ul>
    </li>
    <li class=""><a title="" href="#"><i class="icon icon-cog"></i> <span class="text">设置</span></a></li>
    <li class=""><a title="" href="{:U('Login/logout')}"><i class="icon icon-share-alt"></i> <span class="text">退出</span></a></li>
  </ul>
</div>
<!--close-top-Header-menu-->
<!--start-top-serch-->
<div id="search">
  <input type="text" placeholder="输入搜索内容..."/>
  <button type="submit" class="tip-bottom" title="Search"><i class="icon-search icon-white"></i></button>
</div>
<!--close-top-serch-->
<div id="sidebar"><a href="#" class="visible-phone"><i class="icon-home"></i> 控制台</a>
  <ul>
    <!-- <li><a href="{:U('Index/index')}"><i class="icon-home"></i> <span>首页</span></a> </li>
    <li> <a href="{:U('Log/index')}"><i class="icon-signal"></i> <span>库存单品编码</span></a> </li>
    <li> <a href="{:U('Lsdl/index')}"><i class="icon-signal"></i> <span>客户门店添加</span></a> </li>
    <li class="active"> <a href="{:U('Ls/index')}"><i class="icon-signal"></i> <span>门店报单编辑</span></a> </li>
    <li> <a href="{:U('Lsrb/index')}"><i class="icon-signal"></i> <span>已报订单确认</span></a> </li>
    <li> <a href="{:U('Nslsrb/index')}"><i class="icon-signal"></i> <span>日报新增删除</span></a> </li>
    <li > <a href="{:U('Sc/index')}"><i class="icon-signal"></i> <span>商超批量派车</span></a> </li>
    <li> <a href="{:U('Scdl/index')}"><i class="icon-signal"></i> <span>商超独立派车</span></a> </li>
    <li> <a href="{:U('Wpcmd/index')}"><i class="icon-signal"></i> <span>未派订单处理</span></a> </li>    -->
  </ul>
</div>
<!--sidebar-menu-->

<!--main-container-part-->
<div id="content">
<!--breadcrumbs-->
  <div id="content-header">
    <div id="f"> <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> 首页</a></div>
  </div>
<!-- End-breadcrumbs -->

<!-- Action boxes -->

  <div id="" class="" >
    <div id=""></div> 
    <div id=""> 
    <div> 
    <!-- <form action="{:U('ls/upfile')}" enctype="multipart/form-data" method="post">
	 <input type="file" name="photo" /> <input type="submit" value="提交">
    </form> -->
    <!-- <button id="fbt6">加载配送信息</button>
    <button id="fbt1">追加</button>
	<button id="fbt2">删除</button>
	<button id="fbt3">保存</button>
	<button id="fbt4">预览</button>
	<button id="fbt5">提交</button>
	<button id="fbt7">提交并保存</button>
	<button id="fbt8">删除缓存</button>
	<button id="fbt9">无订单加载缓存</button>
    <datalist id="typelist"> 
    </datalist>-->
    <datalist id="typelist"> 
    </datalist>
              入库日期开始:<input type=date id="dbb1" > 
              入库日期结束:<input type=date id="dbb2" > 
              单品<input type=text list="listItem"  placeholder="请选择单品"  id="dbb3" value="全部" > 
    <datalist  id="listItem">
			  <option>全部</option>						     
	</datalist>
   
	货物类型<select id="dbb4">	
					<option>全部</option>									
					<option>冻货</option>
					<option>鲜货</option>	
					<option>干货</option>										
			</select>	       
	<button id="fbt444">查询数据</button>	
	<button id="fbt555">清空数据</button>	
	<button id="fbt666">导出数据</button>	
	<hr>  	
	添加个数<input type="text" id="dpsm" class="span1" value=1>
	<button id="fbt111">追加</button>		
	<button id="fbt222">删除</button>
	<button id="fbt333">提交</button>	
	</div>   
	    
	<div  class="parent pre-scrollable" ><!-- 与wwf分离，来保存input变量  class="parent pre-scrollable" -->   
    <div  id="wwf"> 
                            <table id=tablea class="table table-bordered table-striped" >							
							<thead>
							<tr>
							    <th><nobr>选中</nobr></th>
							    
							    <th><nobr>序号</nobr></th>
							    <th><nobr>商品编码</nobr></th>
							    <th style="color:#f0f"><nobr>品名</nobr></th>
							    <th><nobr>商品条码</nobr></th>
							    <th><nobr>单品规格</nobr></th>
							    <th><nobr>箱规</nobr></th>
							    <th><nobr>货物类型</nobr></th>
							    <th><nobr>保质期</nobr></th>
							    <th style="color:#f0f"><nobr>备注</nobr></th>
							    <th id="jsjs" style="color:#f0f"><nobr>件数</nobr></th>	
							    <th style="color:#21f"><nobr>单品批次</nobr></th>	
							    <th style="color:#21f"><nobr>真实库存</nobr></th>		
							    <th style="color:#21f"><nobr>入库日期</nobr></th>		
							    <th style="color:#f0f"><nobr>库位</nobr></th>		
							    <th style="color:#21f"><nobr>是否禁止发货</nobr></th>	
							    <th style="color:#f0f""><nobr>入库重量</nobr></th>					    		    						 
							</tr>
							</thead>
							<tbody class="pre-scrollable">
							<volist name="arr1" id="vo">
							<tr>
							    <!-- <th><input type=checkbox name=selected_book_id[] value={$vo.0}></th>						
								<th><nobr>{$vo.1}</nobr></th>								
								<th><nobr>{$vo.2}</nobr></th>
								<td><nobr>{$vo.3}</nobr></td>								
								<th><nobr>{$vo.4}</nobr></th>
								<th><nobr>{$vo.5}</nobr></th>
								<th><nobr>{$vo.6}</nobr></th>
								<td><nobr>{$vo.7}</nobr></td>
								<th><nobr>{$vo.8}</nobr></th>
								<th><nobr>{$vo.9}</nobr></th>		 -->																																				
							</tr>
							</volist>	
							</tbody>							
						</table>     
	</div>    
	</div>
	</div>
	<div id=""></div>
  </div>
<!-- End-Action boxes -->    

</div>

<!--end-main-container-part-->

<!--Footer-part-->

<div class="row-fluid">
  <div id="footer" class="span12">Copyright &copy; 2018.Company name All rights reserved.<a target="_blank" href="http://sc.chinaz.com/moban/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a> </div>
</div>


<script src="__ROOT__/PUBLIC/js/excanvas.min.js"></script> 
<script src="__ROOT__/PUBLIC/js/jquery.min.js"></script> 
<script src="__ROOT__/PUBLIC/js/jquery.ui.custom.js"></script> 
<script src="__ROOT__/PUBLIC/js/bootstrap.min.js"></script> 
<script src="__ROOT__/PUBLIC/js/jquery.flot.min.js"></script> 
<script src="__ROOT__/PUBLIC/js/jquery.flot.resize.min.js"></script> 
<script src="__ROOT__/PUBLIC/js/jquery.peity.min.js"></script> 
<script src="__ROOT__/PUBLIC/js/fullcalendar.min.js"></script> 
<script src="__ROOT__/PUBLIC/js/matrix.js"></script> 
<script src="__ROOT__/PUBLIC/js/matrix.dashboard.js"></script> 
<script src="__ROOT__/PUBLIC/js/jquery.gritter.min.js"></script> 
<script src="__ROOT__/PUBLIC/js/matrix.interface.js"></script> 
<script src="__ROOT__/PUBLIC/js/matrix.chat.js"></script> 
<script src="__ROOT__/PUBLIC/js/jquery.validate.js"></script> 
<script src="__ROOT__/PUBLIC/js/matrix.form_validation.js"></script> 
<script src="__ROOT__/PUBLIC/js/jquery.wizard.js"></script> 
<script src="__ROOT__/PUBLIC/js/jquery.uniform.js"></script> 
<script src="__ROOT__/PUBLIC/js/select2.min.js"></script> 
<script src="__ROOT__/PUBLIC/js/matrix.popover.js"></script> 
<script src="__ROOT__/PUBLIC/js/jquery.dataTables.min.js"></script> 
<script src="__ROOT__/PUBLIC/js/matrix.tables.js"></script> 
<script src="__ROOT__/PUBLIC/js/mindmup-editabletable.js"></script> 
<script src="__ROOT__/PUBLIC/js/numeric-input-example.js"></script> 
<script src="__ROOT__/PUBLIC/js/jquery.mousewheel.js"></script>
<!--end-Footer-part-->
<script type="text/javascript">


//ajax 测试
$.post("__CONTROLLER__/ceshi/",
		    {
		    
		    },
		    function(data,status){	
		    	switch (data) 
		    	{		    	
		        case "1":
		    	{
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Index/index')}'><i class='icon-home'></i> <span>首页</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Log/index')}'><i class='icon-signal'></i> <span>库存单品编码</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Lsdl/index')}'><i class='icon-signal'></i> <span>客户门店添加</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Ls/index')}'><i class='icon-signal'></i> <span>门店报单编辑</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Lsrb/index')}'><i class='icon-signal'></i> <span>已报订单确认</span></a> </li>"); 	
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Dddy/index')}'><i class='icon-signal'></i> <span>订单打印处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li class='active'> <a href='{:U('Rkcl/index')}'><i class='icon-signal'></i> <span>单品入库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Ddgz/index')}'><i class='icon-signal'></i> <span>订单出库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Kcgl/index')}'><i class='icon-signal'></i> <span>库存数据查看</span></a> </li>");
		        	break;
		    	}
		    	
		        case "2":
		    	{
		        	$('#sidebar').children("ul").append("<li><a href='{:U('Index/index')}'><i class='icon-home'></i> <span>首页</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Log/index')}'><i class='icon-signal'></i> <span>库存单品编码</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Lsdl/index')}'><i class='icon-signal'></i> <span>客户门店添加</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Ls/index')}'><i class='icon-signal'></i> <span>门店报单编辑</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Lsrb/index')}'><i class='icon-signal'></i> <span>已报订单确认</span></a> </li>"); 
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Kcgl/index')}'><i class='icon-signal'></i> <span>库存数据查看</span></a> </li>");  
		        break;
		    	}
		    	
		        case "3":
		    	{ 
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Index/index')}'><i class='icon-home'></i> <span>首页</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Log/index')}'><i class='icon-signal'></i> <span>库存单品编码</span></a> </li>");	 
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Dddy/index')}'><i class='icon-signal'></i> <span>订单打印处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li class='active'> <a href='{:U('Rkcl/index')}'><i class='icon-signal'></i> <span>单品入库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Ddgz/index')}'><i class='icon-signal'></i> <span>订单出库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='{:U('Kcgl/index')}'><i class='icon-signal'></i> <span>库存数据查看</span></a> </li>");
		        break;
		    	}
		    	
		        case "4":
		        {    	    	
		        	
		        break;
		        } 
		        
		        default: 
		        {
		    	break;
		        }
		        
		    	} 
		    	//$("#sidebar").find("li")[0].remove();    
		    });
/////////////////////////////////////////////////////////////////////////////////////////////////
//取回单品信息 $sjkTemp [$ii] [dpbzq].",";
	$.post("__CONTROLLER__/ajaxdpbm1/", {

	}, function(data, status) {
					
		dinputlist = data.split(',');//转换为数组		
		$('#listItem').append('<option value=""></option>');//先加个空白值。
   	for (var ig = 0; ig < dinputlist.length; ig=ig+1) 
   		{  	    		    
   			$('#listItem').append('<option value="' + dinputlist[ig] + '"></option>');
   		}   
	});
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//按单品加批次计算 库存数目
var jj1;
$.post("__CONTROLLER__/ajaxdppccx/", {
				
			}, function(data, status) {
				jj1=$.parseJSON(data);	
				//console.log(jj1);
	}); 
/////////////////////////////////////////////////////////////////////////
//today保存当前日期，作为所有需要赋值date的值
////////////////////////////////////////////////////////////////////////
//取得日期
	function getDate(d1) {

		/* var	d2=Number(d1);//转换为数值。
		var time = new Date();
		var day = ("0" + (time.getDate()+d2)).slice(-2);
		
		var month = ("0" + (time.getMonth() + 1)).slice(-2);
		var today = time.getFullYear() + "-" + (month) + "-" + (day);
		
		return today; */
		var d2 = Number(d1);//转换为数值。
		var time = new Date();
		var n = time.getTime();
		//有多少天的间隔就加上相对应的秒数。
		//console.log(n); 
		n = n + d2 * 24 * 60 * 60 * 1000;
		//console.log(n); 

		var dd = new Date(+n+8*3600*1000);
		var today = dd.toISOString();
		return today.slice(0, 10);
		//console.log(n1.slice(0,10)); 
	}
	$('#dbb1').val(getDate(0));
	$('#dbb2').val(getDate(0));
////////////////////////////////////////////////////////////////////////
//清空工作区
	$('#fbt555').click(function(){
		//清空工作区
		 $('#tablea').children('tbody').find("tr").each(function(){ 			   		
			 $(this).empty();		   
		   });
		 bjs=0;
		 cxbj=0;
		 //console.log(cxbj);
	 });
////////////////////////////////////////////////////////////////////////
//入库数据查询
//工作区有数据不可新增 标记
var cxbj=0;
$('#fbt444').click(function(){
	//清空工作区
	 $('#tablea').children('tbody').find("tr").each(function(){ 			   		
		 $(this).empty();
		 bjs=0;
	   });
	   
	
	 $.post("__CONTROLLER__/ajaxmddb/", {				
			arr1:$('#dbb1').val(),
			arr2:$('#dbb2').val(),
			arr3:$('#dbb3').val(),
			arr4:$('#dbb4').val()
		}, function(data, status) {
			//rkdppc":"0000-00-00" ,如果单品没有提交批次，则以"0000-00-00"为标记。input data标记在没有数值的情况下是""空值
			//console.log(data);
			var j1=$.parseJSON(data);	
			for(var i=0;i<j1.length;i++)
			{
				var zskcsj=0;
				for (var it = 0; it < jj1.length; it=it+1)
    			{ 		    			
    			if(j1[i].dpmc==jj1[it]['pinming']&&j1[i].rkdppc==jj1[it]['pici']){		    						  
    				zskcsj=jj1[it]['zskc'];
    			break;
    			}
    			zskcsj='仓库无货，新品入库';		    				    					
    			}	
				bjs=bjs+1;
				/* var temp=0;
				var bcs=Number(j1[i].djzlkg);
	    		var cs=Number(j1[i].rksl);
	    		if(!isNaN(cs)&&!isNaN(bcs)){
	    			 temp=cs/bcs;	    			
	    		} */
	    		
				$('#tablea').children('tbody').append('<tr>'
				        +'<th><input type=checkbox value='+j1[i].id+'></th>'
				        +'<th>'+bjs+'</th>'
				        +'<th>'+j1[i].hpbm+'</th>'
				        +'<td>'+j1[i].dpmc+'</td>'				        
				        +'<th>'+j1[i].sptm+'</th>'
				        +'<th>'+j1[i].dpgg+'</th>'
				        +'<th>'+j1[i].djzlkg+'</th>'
				        +'<th>'+j1[i].hwlx+'</th>'
				        +'<th>'+j1[i].dpbzq+'</th>'
					    +'<td>'+j1[i].dpbz+'</td>'    
					    +'<td>'+j1[i].rksl+'</td>'
			            +'<th><input type=date value='+j1[i].rkdppc+'></th>'
			            +'<th>参考总库存:'+zskcsj+'</th>'
			            +'<th><input type=date value='+j1[i].rkrq+'></th>'	
			            +'<td>'+j1[i].dpkw+'</td>'
			            +'<th><select>'
			            +'<option value ='+j1[i].jzfhbj+'>'+j1[i].jzfhbj+'</option>'
			            +'<option value ='+j1[i].jzfhbj1+'>'+j1[i].jzfhbj1+'</option>'				           
			            +'</select></th>'
			            +'<td>'+j1[i].rkcmzl+'</td>'
			            +'</tr>');
			}
			
			$('#tablea').unbind();
			$('#tablea').editableTableWidget();
			$('#tablea').on('click keypress dblclick', showEditordp);
			cxbj=1;
			 //console.log(cxbj);
		    //console.log(j1.length);
		}); 
});
//删除
$('#fbt222').click(function(){
	var  temp2Arr="";//缓存check 
    
    //input:checkbox:checked 选中input下的checkbox的checked选中值。
  	 $('#tablea').find("input:checkbox:checked").each(function(){
  		var temp=$(this).val();
  		   $('#tablea').children('tbody').find("tr").each(function(){ 			   
  	      	  if(temp==$(this).find("input:checkbox:checked").val())
  	      	  {   
  	      		temp2Arr = temp2Arr + temp + ",";
  			   $(this).remove();//先找到table的选中复选框值，再用这个值与table表体中每一行tr中的复选框值比对，两个值相同就删除当前行。   			  
  	      	  }
  	      	  });//从表格体中查找tr行，并找到每行中check-box的值。        		   
    	   });
  	var temp2 = temp2Arr;
  	alert(temp2);
  	 $.post("__CONTROLLER__/tjajaxsjsc/",
   		    { 		      
   		      arr2:temp2, 		     
   		    },
   		    function(data,status){ 		    	
   		    	//console.log(data);//配合 var_dump 可以实现对ajax 处理过程的监控。    		    	 		    	
   		    });	 	
	//更新件数
  	 var jsqhjs=0;
    	$('#tablea').find('tbody td').each(function () {
    		if($(this).index()==10){
    			 var temparr=Number($(this).text());
    			 if(!isNaN(temparr)){
    				 jsqhjs=jsqhjs+temparr;
    			 }else{
    				 //不是 数字 归零
    				 $(this).text(0)
    				
    			 }		    			
    		}		    		
		});
    $('#jsjs').text('件数'+'('+jsqhjs+')');
    //重绘序号
    var jsxuhao=1;
	$('#tablea').find('tbody th').each(function () {
		//console.log($(this).index());
		//console.log($(this).text());
		if($(this).index()==1){
			$(this).text(jsxuhao);
			jsxuhao=jsxuhao+1;
			 }	    			  				    		
	});
	bjs=jsxuhao-1;
});
	
//新增
    var bjs=0
	$('#fbt111').click(function(){
		if(cxbj==0){
		var temp=Number($('#dpsm').val())
		
		 if(!isNaN(temp))
			{
			   for(var aaa=0;aaa<temp;aaa++)
			   {
				bjs=bjs+1
				$('#tablea').children('tbody').append('<tr><th><input type=checkbox value=a99999></th><th>'+bjs+'</th><th></th><td></td><th></th><th></th><th></th><th></th><th></th>'
						    +'<td></td>'    
						    +'<td>0</td>'
				            +'<th><input class=rkpcbj type=date></th>'
				            +'<th></th>'
				            +'<th><input type=date value='+getDate(0)+'></th>'		
				            +'<td></td>'
				            +'<th><select>'
				            +'<option value ="正常">正常</option>'
				            +'<option value ="禁止发货">禁止发货</option>'				           
				            +'</select></th>'
				            +'<td>1</td>'    
				            +'</tr>'		           
				            );  							
			   }
				
			}
		 		
		 $('#tablea').unbind();
		 var iDatejsdt = "<script type='text/javascript'>";				
			iDatejsdt = iDatejsdt
			        + "$('.rkpcbj').blur(function(e) {"		
			          //真实库存判定
			        //+ "console.log($(this).val());"
	    			+ "var datetemp='';"
	    			+ "if($(this).val()==''){"
	    			+ "datetemp='0000-00-00'"		    	        	  
	    			+ "}else{"
	    			+ "datetemp=$(this).val();	"	    	        	  
	    			+ "}"
	    			  //更新数据时找到对应库存。
	    			+ "var fystemp=$(this).parent().parent().find('td').eq(0).text();" 
	    			//+ "console.log(fystemp);"
	    			+ "for (var it = 0; it < jj1.length; it=it+1)" 
	    			+ "{" 		    			
	    			+ "if(fystemp==jj1[it]['pinming']&&datetemp==jj1[it]['pici']){"		    						  
	    			+ "$(this).parent().parent().find('th').eq(9).text('参考库存:'+jj1[it]['zskc']);"
	    			+ "break;"
	    			+ "}"
	    			+ "$(this).parent().parent().find('th').eq(9).text('仓库无货，新品入库');"		    				    					
	    			+ "}"				        
			        + "e.preventDefault();"
			        + "e.stopPropagation();"					       
			        + "});" 
					"<\/script>";
		 $('#wwf').append(iDatejsdt);
		 $('#tablea').editableTableWidget();
		 $('#tablea').on('click keypress dblclick', showEditordp);
		}else{
    		alert("工作区有内容，清空后再新增！");
    	}
	});
	
	
	//提交 
    $('#fbt333').click(function(){
    	
    	var r=confirm("是否提交!");
   		if (r==true)
   		{   
   			var temp1Arr = "";
			var temp2Arr = "";
			var temp3Arr = "";
			var temp4Arr = "";
			
		    var sjjcbj=0;
			$('#tablea').children("tbody").children("tr")
						.children("td").each(function() {
							var temp = $(this).text();
							temp1Arr = temp1Arr + temp + ",";
							if($(this).index()==3||$(this).index()==10){
								if($(this).text()==""||$(this).text()==0)
									{
									//品名和件数一个为空 就做出提示
									sjjcbj=1;
									//console.log(sjjcbj);
									}
							}
						});
			$('#tablea').children("tbody").children("tr")
						.children("th").each(function() {
							var temp = $(this).text();
							temp2Arr = temp2Arr + temp + ",";
						});	
			$('#tablea').children("tbody").children("tr")
			.find("input").each(function() {
				var temp = $(this).val();
				temp3Arr = temp3Arr + temp + ",";
			});		
            
			$('#tablea').children("tbody").children("tr").find("select").each(function() {
				var temp = $(this).val();
				temp4Arr = temp4Arr + temp + ",";
			});	
            
			var temp1 = temp1Arr.slice(0, temp1Arr.length - 1);
			var temp2 = temp2Arr.slice(0, temp2Arr.length - 1);
			var temp3 = temp3Arr.slice(0, temp3Arr.length - 1);
			var temp4 = temp4Arr.slice(0, temp4Arr.length - 1);
			//console.log(temp1);
		    //console.log(temp2);
			//console.log(temp3);
			console.log(temp4);
			if(sjjcbj==0){
			if(bjs>0)
			{
								
				 $.post("__CONTROLLER__/ajaxtjsj/", {				
					arr1:temp1,
					arr2:temp2,
					arr3:temp3,	
					arr4:temp4,	
					user:$('#userbeifn').text()				
				}, function(data, status) {
				    console.log(data);
				}); 
						
				//删除所有tr行
				$('#tablea').children('tbody').find("tr").each(function(){ 			       	      	
	     			   $(this).remove(); 			       	      	 
	     	     });
				//重置序号 
				bjs=0;
				//重置计算件数
				$('#jsjs').text('件数'); 
				alert("已提交!");
			}else{
				alert("请检查工作区是否有数据!");
			}	
			}else{
				alert("品名或者件数有空值or0，请检查!");
			}
            $.post("__CONTROLLER__/ajaxdppccx/", {
				
			}, function(data, status) {
				jj1=$.parseJSON(data);	
				//console.log(jj1);
	        }); 
 		}
 		else
 		{			
 		    alert("未提交!");
 		}
    	
	});

   var act;//这个变量在js中赋值，保存当前表格td焦点。  
   var inputlist="";//缓存单品信息。
   //取回单品信息
	$.post("__CONTROLLER__/ajaxdpbm/", {

	}, function(data, status) {
					
		inputlist = data.split(',');//转换为数组		
		//console.log(inputlist);
	});
   //生成下拉列表框。
	function showEditordp()
	{  
		
		
		 $('#typelist').empty();//删除datalist的所有子元素。
		 switch (act.index()) 
		 {
		    case 3:
		    	{ 	    
		    	$('#typelist').append('<option value=""></option>');//先加个空白值。
		    	for (var ig = 0; ig < inputlist.length; ig=ig+10) 
		    		{  	    		    
		    			$('#typelist').append('<option value="' + inputlist[ig+2] + '"></option>');
		    		}   
		        break;
		    	}
		    	    
		    default: 
		        {
		    	break;
		        }
		} 
		
	}

	$('#wwf').parent().find("input").blur(function(e){	
		 //console.log(act.text());
		 //console.log(act.index());
		 switch (act.index()) 
		 {
		    case 3:
		    	{ 	
		    	 //act 的父元素是 tr ，找到tr的最后一个th
	    		 //console.log(act.parent().html());
	    		 //console.log(act.parent().find('th').last().text());
	    		 //console.log(act.parent().find('th').eq(5).text());
	    		 //console.log(act.parent().find('td').eq(2).text());
	    		
		    	//以index标记对当前单元格的同辈进行赋值。
		    	for (var ig = 0; ig < inputlist.length; ig=ig+10) 
		    		{ 
		    		
		    		//清空开关
		    	     var qkkg=0;
		    			if(act.text()==inputlist[ig+2]){
		    			  act.prev().text(inputlist[ig+1]);
		    			  act.next().text(inputlist[ig+3]);
		    			  act.next().next().text(inputlist[ig+4]);
		    			  act.next().next().next().text(inputlist[ig+5]);
		    			  act.next().next().next().next().text(inputlist[ig+8]);
		    			  act.next().next().next().next().next().text(inputlist[ig+9]);
		    			  //真实库存判定
		    			  var datetemp="";
		    	          if(act.parent().find("input").eq(1).val()==""){
		    	        	  datetemp="0000-00-00"		    	        	  
		    	          }else{
		    	        	  datetemp=act.parent().find("input").eq(1).val();		    	        	  
		    	          }
		    			  //更新数据时找到对应库存。
		    				for (var it = 0; it < jj1.length; it=it+1) 
				    		{ 
		    					
		    					if(act.text()==jj1[it]["pinming"]&&datetemp==jj1[it]["pici"]){		    						  
		    						act.next().next().next().next().next().next().next().next().next().text(jj1[it]["zskc"]);
		    						//找到数据就退出当前 for循环。
		    						break;
		    					}	
		    					act.next().next().next().next().next().next().next().next().next().text(('仓库无货，新品入库'));	
				    		}
		    			  break;
		    		    }else{
		    		    
		    		    	//没有找到变为1 
		    		    	qkkg=1;
		    		    	
		    		    } 	
		    			//阻止默认行为，停止冒泡
					
		    		}
		    
		    	//清空
		    	if(qkkg==1){
		    		 act.text("");   		    	
		    		 act.prev().text("");
	    			 act.next().text("");
	    			 act.next().next().text("");
	    			 act.next().next().next().text("");
	    			 act.next().next().next().next().text("");
	    			 act.next().next().next().next().next().text("");
	    			 alert("单品不在库存或单元格为空，请添加！");
		    	}
		    	/*  var bcs=Number(act.parent().find('th').eq(5).text());
	    		 var cs=Number(act.parent().find('td').eq(2).text());
	    		 if(!isNaN(cs)&&!isNaN(bcs)){
	    			 var temp=cs/bcs;
	    			 act.parent().find('th').last().text(temp);
	    		 } */
		    	e.stopPropagation();
				return false;
		        break;
		    	}
		    case 10:
	    	{ 	    
		    	
		    	
	    		 
	    	    var jsqhjs=0;
		    	$('#tablea').find('tbody td').each(function () {
		    		if($(this).index()==10){
		    			 var temparr=Number($(this).text());
		    			 if(!isNaN(temparr)){
		    				 jsqhjs=jsqhjs+temparr;
		    			 }else{
		    				 //不是 数字 归零
		    				 $(this).text(0);
		    				 alert("件数字段不是数字");
		    			 }		    			
		    		}		    		
				});
		    	$('#jsjs').text('件数'+'('+jsqhjs+')');
		    	
		    	 /* var bcs=Number(act.parent().find('th').eq(5).text());
	    		 var cs=Number(act.parent().find('td').eq(2).text());
	    		 if(!isNaN(cs)&&!isNaN(bcs)){
	    			 var temp=cs/bcs;
	    			 act.parent().find('th').last().text(temp);
	    		 } */
		    	//阻止默认行为，停止冒泡
				e.stopPropagation()
				return false;
	            break;
	    	}
		    case 16:
	    	{ 
		     //index 在16时触发。	 
			 $('#tablea').find('tbody td').each(function () {
			    		if($(this).index()==16){
			    			 var temparr=Number($(this).text());
			    			 if(!isNaN(temparr)){
			    				
			    			 }else{
			    				 //不是 数字 归零
			    				 $(this).text(0);
			    				 alert("件数字段不是数字");
			    			 }		    			
			    		}		    		
					});
		    	e.stopPropagation();
				return false;
	            break;		    	
	    	}	    
		    default: 
		        {
		    	break;
		        }
		} 	    					 
	  });

</script>
</body>
</html>
  